<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增家庭背景')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form id="form-family-add" class="form-horizontal" AUTOCOMPLETE="OFF">
        <input name="id" type="hidden" id="id" th:value="${id}"/>
        <h4 class="form-header h4">家庭背景</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">亲属姓名：</label>
                    <div class="col-sm-8">
                        <input name="fname" id="fname" class="form-control" type="text"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">家属关系：</label>
                    <div class="col-sm-8">
                        <select name="relation" id="relation" class="form-control m-b"
                                th:with="type=${@dict.getType('eCD_Relation')}">
                            <option value="">请选择</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select></div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">性别：</label>
                    <div class="col-sm-8">
                        <select name="gender" id="gender" class="form-control m-b"
                                th:with="type=${@dict.getType('eCD_Gender')}">
                            <option value="">请选择</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">出生日期：</label>
                    <div class="col-sm-8">
                        <input name="Birthday" id="Birthday"  class="form-control laydate-demo-1" type="text"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">工作单位：</label>
                    <div class="col-sm-8">
                        <input name="Company" id="Company" class="form-control" type="text"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">担任职务：</label>
                    <div class="col-sm-8">
                        <input name="Job" id="Job" class="form-control" type="text"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">联系电话：</label>
                    <div class="col-sm-8">
                        <input name="tel" id="tel" class="form-control" type="text"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">备注：</label>
                    <div class="col-sm-8">
                        <input name="remark" id="remark" class="form-control" type="text"/>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>

<script th:inline="javascript">

    var prefix = ctx + "entryManage/EntryBackground";

    $(function () {

        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.laydate-demo-1',
                type: 'date'
            });
        });
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-family-add").serializeArray();
            var id = $("#id").val();
            var relation = $("#relation").val();
            var gender = $("#gender").val();
            var Birthday = $("#Birthday").val();
            var Company = $("#Company").val();
            var Job = $("#Job").val();
            var tel = $("#tel").val();
            var remark = $("#remark").val();

            data.push({"name": "id", "value": id});
            data.push({"name": "relation", "value": relation});
            data.push({"name": "gender", "value": gender});
            data.push({"name": "Birthday", "value": Birthday});
            data.push({"name": "Company", "value": Company});
            data.push({"name": "Job", "value": Job});
            data.push({"name": "tel", "value": tel});
            data.push({"name": "remark", "value": remark});
            $.operate.save(prefix + "/addFamily", data);

        }
    }


</script>
</body>
</html>
